/**
 * @ author: 汪孟苹
 */
define(["jquery","bbcare"],function ($,$bb) {
    var servers = {};
    var URL = $bb.baseUrl("followup");
    /**
     * 获取从阶段调查评估list页面带过来的参数
     */
    var getPageParams = function(){
    	return	$bb.getPageParams();
    }
    /**
     * 请求阶段调查评估问卷
     */
    servers.ajaxQuest = function(callback,params){
        $bb.ajax({
			url: URL + "followup/service/patientFollow/queryFuAssessContTmpl",
			data:JSON.stringify({
				data : {
					"busiId":getPageParams().busiId
				}
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params);
				}else{
					$bb.toastShow(data.msg ? data.msg : "阶段调查评估问卷加载失败！");
				}
			}
		});
    }
    /**
     * 保存阶段调查评估问卷
     */
    servers.ajaxSaveQuest = function(questiones,callback,params){
    	var pageParams = getPageParams();
    	var sessinonUserName = JSON.parse($bb.getSessionStorage("account")).alias;
        $bb.ajax({
			url: URL + "followup/service/patientFollow/submitPtFuAssessCont",
			data:JSON.stringify({
				data : {
					"busiInfo":{
						"busiId":pageParams.busiId,
						"patientId":pageParams.patientId,
						"tmplVerInfo":params.tmplVerInfo
					},
				    "oprInfo":{
				        "opCode":"1019",
				        "opNote":"【" + sessinonUserName + "】医生给【" + pageParams.patientName + "】患者填写了【" + params.quesName + "】",
				        "opType":"2"
				    },
				    "questiones":questiones
				}
			}),
			success: function(data){
				if(data.success){
					callback(data.data,params);
				}else{
					$bb.toastShow(data.msg ? data.msg : "阶段调查评估问卷保存失败！");
				}
			}
		});
    }

    return servers;
});